package com.kimehwa.studyboot.hutools;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @author xiaodongguan
 * @description
 * @since 2021-11-08 15:37
 */

@SpringBootTest
@Slf4j
public class testSnowId {
    // 单例的bean 默认为单例
    Snowflake snowflake = IdUtil.getSnowflake(1, 1);

    @Test
    public void testId(){
        for(int i = 0;i<100;i++){
            //生成的雪花id不是+1连续的
            log.info("生成的snowid:{}",getId());
        }
    }

    private Long getId(){
        return snowflake.nextId();

    }
}
